<template>
  <div>
    <page-list :x-uri="uri" :doactions="doactions" :custom-components="custom" :checkbox-item="false">
      <!-- 自定义tab -->
      <template v-slot:page-tabs>
        <tabs />
      </template>
    </page-list>
  </div>
</template>

<script>
import PageList from '@public/template/page_list.vue';
import Money from './components/money.vue';
import Status from './components/status';
import Type from './components/type';
import Tabs from './components/tabs.vue';
export default {
  components: {
    PageList,
    Tabs
  },
  inject: ['reload'],
  data() {
    return {
      uri: '/admin/finance/encashment/done',
      tabs: [
        {
          title: '待审核提现',
          uri: '/finance/encashment/wait',
          meta: {
            permission: 'finance.encashment.wait'
          }
        },
        {
          title: '已完成提现',
          uri: '/finance/encashment/done',
          meta: {
            permission: 'finance.encashment.done'
          }
        },
        {
          title: '已驳回提现',
          uri: '/finance/encashment/reject',
          meta: {
            permission: 'finance.encashment.reject'
          }
        }
      ],
      doactions: [
        { title: '查看', meta: { permission: 'finance.encashment.done.detail' }, callback: this.update },
        { title: '删除', meta: { permission: 'finance.encashment.done.delete' }, callback: this.delete }
      ],
      custom: {
        status: Status,
        type: Type,
        money: Money
      }
    };
  },
  methods: {
    update: function({ row }) {
      this.$router.push({ path: '/finance/encashment/' + row.order_no + '/fetch' });
    },
    delete: function({ row }) {
      this.$box
        .confirm('确认删除吗')
        .then(() => {
          this.$http.delete(
            '/admin/finance/encashment/' + row.order_no + '/delete',
            {},
            response => {
              this.$message.success(response.msg, _ => {
                this.reload();
              });
            },
            error => {
              this.$message.error(error.msg);
            }
          );
        })
        .catch(() => {});
    }
  }
};
</script>
